var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, n, a) {
    var o, i = arguments.length, s = i < 3 ? t : null === a ? a = Object.getOwnPropertyDescriptor(t, n) : a;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, a); else for (var r = e.length - 1; 0 <= r; r--) (o = e[r]) && (s = (i < 3 ? o(s) : 3 < i ? o(t, n, s) : o(t, n)) || s);
    return 3 < i && s && Object.defineProperty(t, n, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameManager"), s = e("AudioManager"), c = e("Player"), l = e("BaseView"), d = e("RecorderManager"), u = e("GameConfig"), p = e("GameData"), h = e("WebManager"), f = e("UIManager"), g = e("AdManager"), m = cc._decorator, y = m.ccclass, v = m.property, w = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.videoBtn = null, e.shareBtn = null, e.recorderBtn = null, e.player = null, 
        e.shadow = null, e.sprite = null, e.btns = null, e.imageList = [], e.isPause = !1, 
        e.isRecorder = !1, e;
    }
    return i(e, t), e.prototype.onEnable = function() {
        var e = this;
        this.sprite && (this.sprite.spriteFrame = this.imageList[0]);
        var t = 0;
        this.schedule(function() {
            e.isPause || (++t < e.imageList.length && e.sprite && (e.sprite.spriteFrame = e.imageList[t]), 
            5 == t && (e.hidePnl(), e.check()));
        }, 1);
    }, e.prototype.onDisable = function() {
        this.unscheduleAllCallbacks(), g.default.getInstance().hideAllBanner();
    }, e.prototype.onClickVideo = function() {
        var t = this;
        if (GA.Info.underCheck && u.GC.isDebug) return cc.systemEvent.emit("videoEnd", "lose"), 
        void this.callback();
        h.default.getInstance().sentLog("点击失败界面视频复活按键"), r.default.getInstance().pause(), 
        GA.rewardOperation({
            tag: "lose",
            page: "",
            byVideo: !0,
            result: function(e) {
                e.reward ? (cc.systemEvent.emit("videoEnd", "lose"), r.default.getInstance().resume(), 
                cc.isValid(t) && t.callback()) : e.shown || (r.default.getInstance().resume(), f.default.getInstance().loadPnl("msg", r.default.getInstance().gameView.node.getChildByName("ctl")).then(function(e) {
                    e instanceof l.default && e.init({
                        str: "视频播放失败"
                    });
                }));
            }
        });
    }, e.prototype.onClickShare = function() {
        var t = this;
        GA.Info.underCheck && u.GC.isDebug ? this.callback() : (h.default.getInstance().sentLog("点击失败界面分享复活按键"), 
        GA.rewardOperation({
            tag: "lose",
            page: "",
            byVideo: !1,
            result: function(e) {
                e.reward && cc.isValid(t) && t.callback();
            }
        }));
    }, e.prototype.onClickRecorder = function() {
        var t = this;
        GA.Info.underCheck && u.GC.isDebug ? this.callback() : (h.default.getInstance().sentLog("点击失败界面录屏复活按键"), 
        h.default.getInstance().sentLog("TryShareVideo"), GA.isByteDance() && !this.isRecorder && (this.isRecorder = !0, 
        cc.game.pause(), GA.PA.shareAppMessage({
            channel: "video",
            title: "我就要吃鸡",
            desc: "进入吃鸡的世界",
            imageUrl: "",
            templateId: "3eld33adx4d3bk46j6",
            query: "krq_wjycj=10002",
            extra: {
                videoPath: d.default.getInstance().videoPath,
                videoTopics: [ "我就要吃鸡", "卡日曲游戏" ],
                withVideoId: !0,
                createChallenge: !1
            },
            success: function(e) {
                cc.game.resume(), h.default.getInstance().sentLog("ShareVideoSuccess"), e.videoId && h.default.getInstance().saveVideoId({
                    aliasId: e.videoId,
                    success: function(e) {
                        console.log("保存视频成功:", e);
                    }
                }), console.log("分享视频成功:", e), t.isRecorder = !1, t.callback();
            },
            fail: function(e) {
                cc.game.resume(), h.default.getInstance().sentLog("ShareVideoFailed"), "shareAppMessage:cancel" == e.errMsg || "shareAppMessage:fail video duration is too short" == e.errMsg && f.default.getInstance().showToast({
                    str: "抱歉,录屏时间太短！"
                }), console.log("分享视频失败:", e), t.isRecorder = !1;
            }
        })));
    }, e.prototype.onClickRestart = function() {
        var e, t;
        s.default.getInstance().playAudio("按钮2"), p.GD.updateNumber("diamond", -30) ? this.callback() : null === (t = null === (e = GA.PA) || void 0 === e ? void 0 : e.showToast) || void 0 === t || t.call(e, {
            title: "钻石不足",
            icon: "none"
        });
    }, e.prototype.onClickClose = function() {
        this.isPause || (s.default.getInstance().playAudio("按钮2"), this.hidePnl(), this.check());
    }, e.prototype.changeBtn = function(e) {
        e ? (this.videoBtn && (this.videoBtn.node.active = !1), GA.isByteDance() && d.default.getInstance().videoPath ? this.recorderBtn && (this.recorderBtn.node.active = !0) : this.shareBtn && (this.shareBtn.node.active = !0)) : (this.videoBtn && (this.videoBtn.node.active = !0), 
        this.shareBtn && (this.shareBtn.node.active = !1), this.recorderBtn && (this.recorderBtn.node.active = !1));
    }, e.prototype.start = function() {
        GA.isPlatform(GA.Platform.ByteDance) ? this.btns.active = !1 : this.changeBtn(!GA.isNextRewardVideo("lose"));
    }, e.prototype.callback = function() {
        this.player && (r.default.getInstance().restartcount++, this.player.restart()), 
        this.hidePnl();
    }, e.prototype.hidePnl = function() {
        this.unscheduleAllCallbacks(), this.shadow && (this.shadow.active = !1), this.node && (this.node.active = !1);
    }, e.prototype.check = function() {
        r.default.getInstance().matchType != r.MatchType.三对三 || r.default.getInstance().checkGame() ? r.default.getInstance().endGame() : r.default.getInstance().visitGame();
    }, a([ v(cc.Button) ], e.prototype, "videoBtn", void 0), a([ v(cc.Button) ], e.prototype, "shareBtn", void 0), 
    a([ v(cc.Button) ], e.prototype, "recorderBtn", void 0), a([ v(c.default) ], e.prototype, "player", void 0), 
    a([ v(cc.Node) ], e.prototype, "shadow", void 0), a([ v(cc.Sprite) ], e.prototype, "sprite", void 0), 
    a([ v(cc.Node) ], e.prototype, "btns", void 0), a([ v([ cc.SpriteFrame ]) ], e.prototype, "imageList", void 0), 
    a([ y ], e);
}(cc.Component);

n.default = w;